package chapter1.section1;

import org.junit.Test;

public class ReverseWords {

	public void reverseWords(String[] s, int from, int to) {
		while(from < to) {
			String t = s[from];
			s[from++] = s[to];
			s[to--] = t;
		}
	}
	
	public void leftRotationString(String[] s, int n, int m) {
		//若要左移动大于n位，那么%n是等价的
		//n是字符串长度，m是要反转的前m个字符串，是一个分割节点
		
		reverseWords(s, 0, n-1);
	}
	
	//测试方法
		@Test
		public void test() {
			String str = "I am a student.";
			String[] s = str.split(" ");
			leftRotationString(s,s.length,0);
			for(String c : s) {
				System.out.print(c+" ");
			}
		}
}
